{include file="header.html"}
<script type="text/javascript">
    $(function() {
        var vali=$('#register_form').validate({
            errorPlacement: function(error, element) {
                var error_td = element.parent('dd');
                error_td.find('label').hide();
                error_td.append(error);
            },
            success: function(label) {
                label.addClass('validate_right').text('OK!');
            },
            onkeyup: false,
            rules: {
                // user_name: {
                //     required: true,
                //     byteRange: [3, 15, '{$charset}'],
                //     remote: {
                //         url: 'index.php?app=member&act=check_user&ajax=1',
                //         type: 'get',
                //         data: {
                //             user_name: function() {
                //                 return $('#user_name').val();
                //             }
                //         },
                //         beforeSend: function() {
                //             var _checking = $('#checking_user');
                //             _checking.prev('.field_notice').hide();
                //             _checking.next('label').hide();
                //             $(_checking).show();
                //         },
                //         complete: function() {
                //             $('#checking_user').hide();
                //         }
                //     }
                // },
                phone_mob: {
                    required: true,
                    number: true,
                    byteRange: [11, 11, '{$charset}'],
                    remote: {
                        url: 'index.php?app=member&act=check_mobile&type=register',
                        type: 'get',
                        data: {
                            phone_mob: function() {
                                return $('#phone_mob').val();
                            }
                        },
                        beforeSend: function() {
                            var _checking = $('#checking_mobile');
                            _checking.prev('.field_notice').hide();
                            _checking.next('label').hide();
                            $(_checking).show();

                        },
                        complete: function() {

                            $('#checking_mobile').hide();
                        }
                    }
                },
                confirm_code: {
                    required: true,
                    number: true,
                    byteRange: [6, 6, '{$charset}'],
                    remote: {
                        url: 'index.php?app=member&act=cmc&ajax=1',
                        type: 'get',
                        data: {
                            confirm_code: function() {
                                return $('#confirm_code').val();
                            }
                        },
                        beforeSend: function() {
                            var _checking = $('#checking_code');
                            _checking.next('label').hide();
                            $(_checking).show();

                        },
                        complete: function() {
                            $('#checking_code').hide();
                        }
                    }
                },
                password: {
                    required: true,
                    minlength: 6
                },
                password_confirm: {
                    required: true,
                    equalTo: '#password'
                },
                email: {
                    required: true,
                    email: true,
                    remote: {
                        url: 'index.php?app=member&act=check_email&ajax=1',
                        type: 'get',
                        data: {
                            email: function() {
                                return $('#email').val();
                            }
                        },
                        beforeSend: function() {
                            var _checking = $('#checking_user');
                            _checking.prev('.field_notice').hide();
                            _checking.next('label').hide();
                            $(_checking).show();
                        },
                        complete: function() {
                            $('#checking_user').hide();
                        }
                    }
                },
                captcha: {
                    required: true,
                    remote: {
                        url: 'index.php?app=captcha&act=check_captcha',
                        type: 'get',
                        data: {
                            captcha: function() {
                                return $('#captcha1').val();
                            }
                        }
                    }
                },
                agree: {
                    required: true
                }
            },
            messages: {
                // user_name: {
                //     required: '{$lang.user_name_required}',
                //     byteRange: '{$lang.user_name_limit}',
                //     remote: '{$lang.user_already_taken}'
                // },
                phone_mob: {
                    required: '{$lang.phone_mob_required}',
                    number: '{$lang.phone_mob_number}',
                    byteRange: '{$lang.phone_mob_limit}',
                    remote: '{$lang.mobile_already_exsit}'
                },
                confirm_code: {
                    required: '{$lang.mobile_code_required}',
                    number: '{$lang.mobile_code_must_be_number}',
                    byteRange: '{$lang.mobile_code_limit}',
                    remote: '{$lang.mobile_code_error}'
                },
                password: {
                    required: '{$lang.password_required}',
                    minlength: '{$lang.password_length_limit}'
                },
                password_confirm: {
                    required: '{$lang.password_confirm_please}',
                    equalTo: '{$lang.password_inconsistent}'
                },
                email: {
                    required: '{$lang.email_required}',
                    email: '{$lang.email_invalid}',
                    remote: '{$lang.email_already_taken}'
                },
                captcha: {
                    required: '{$lang.captcha_required}',
                    remote: '{$lang.captcha_error}'
                },
                agree: {
                    required: '{$lang.agree_required}'
                }
            }
        });


       
        var time = 60;
        var dtime = 60;
        $("#sendsms").bind('click', function() {
            if(!vali.element($("[name=phone_mob]"))){
                return;
            }
            var btn = $(this);
           
            var sendaddress = $('#phone_mob').val();
            var fhm = $("label[for='phone_mob']").text();
            if (fhm != '' && fhm != "OK!") {
                alert(lang.pls_enter_right_phone);
                return;
            }
            btn.attr("disabled","true");
            $.getJSON('index.php?app=member&act=send_code&type=register', {mobile: sendaddress}, function(result)
            {
                console.log(result);
                if (result.done == true) {
                    var hander = setInterval(function() {
                        if (time <= 0) {
                            clearInterval(hander);
                            btn.val(lang.resend_msg);
                            btn.removeAttr("disabled");
                            time = dtime;
                        } else {
                            canSend = false;
                            btn.attr({
                                "disabled": "true"
                            });
                            btn.val(time + lang.after_minut_send);
                            time--;
                        }
                    },1000);
                    alert(lang.msg_has_send + sendaddress +lang.pls_check_receive);                    
                    btn.removeAttr("disabled");
                } else {                    
                    alert(result.msg);
                    btn.removeAttr("disabled");
                }
            });
        });
    });
</script>
<script type="text/javascript">
    $(function() {
        // poshytip_message($('#user_name'));
        poshytip_message($('#password'));
        poshytip_message($('#password_confirm'));
        poshytip_message($('#email'));
        poshytip_message($('#captcha1'));
    });
</script>
<div id="main" class="w-full">
                <div area="fp_left" widget_type="area" style="position:absolute;width:100%;">
                    <!--{widgets page=register area=fp_left}-->
                </div>
    <div id="page-register" class="login-register">
        <div class="w clearfix">
       
            <div class="col-sub">
                <div class="form clearfix">
                    <div class="title">
                        <h2>{$lang.user_register}</h2>
                        <a href="index.php?app=member&act=login" class="fr">{$lang.login}</a>
                    </div>
                    <div class="content">
                        <form name="" id="register_form" method="post" action="">
                            <dl class="clearfix">
                                <dt>{$lang.password}</dt>
                                <dd>
                                    <input class="input" type="password" id="password" name="password" title="{$lang.password_tip}" />
                                    <div class="clr"></div><label></label>
                                </dd>
                            </dl>
                            <dl class="clearfix">
                                <dt>{$lang.password_confirm}</dt>
                                <dd>
                                    <input class="input" type="password" id="password_confirm" name="password_confirm" title="{$lang.password_confirm_tip}" />
                                    <div class="clr"></div><label></label>
                                </dd>
                            </dl>
                            <!--{if $msg_enabled}-->
                            <dl class="clearfix">
                                <dt>{$lang.phone_mob}</dt>
                                <dd>
                                    <input type="text" id="phone_mob" name="phone_mob" class="input" maxlength="11" />
                                    <br /><label></label>
                                </dd>
                            </dl>
                            <dl class="clearfix">
                                <dt>{$lang.confirm_code}</dt>
                                <dd>
                                    <input class="input" type="text" id="confirm_code" name="confirm_code" value=""/>
                                    <br /><label></label>
                                </dd>
                            </dl>
                            <dl class="clearfix">
                                <dt>&nbsp;</dt>
                                <dd>
                                    <input type="button" id="sendsms" value="{$lang.send_code}"/>
                                    <br /><label></label>
                                </dd>
                            </dl>
                            <!--{/if}-->
                            <dl class="clearfix">
                                <dt>{$lang.email}</dt>
                                <dd>
                                    <input class="input" type="text" id="email" name="email" title="{$lang.email_tip}" />
                                    <div class="clr"></div><label></label>
                                </dd>
                            </dl>
                            <!--{if $captcha}-->
                            <dl class="clearfix">
                                <dt>{$lang.captcha}</dt>
                                <dd class="captcha clearfix">
                                    <input type="text" class="input float-left" name="captcha"  id="captcha1" title="{$lang.captcha_tip}" />
                                    <img height="30" id="captcha" src="index.php?app=captcha&amp;{$random_number}" class="float-left" />
                                    <a href="javascript:change_captcha($('#captcha'));" class="float-left">{$lang.next_captcha}</a>
                                    <div class="clr"></div><label></label>
                                </dd>
                            </dl>
                            <!--{/if}-->
                            <dl class="clearfix">
                                <dt>&nbsp;</dt>
                                <dd class="mall-eula">
                                    <input id="clause" type="checkbox" name="agree" value="1" class="agree-checkbox" checked="checked" />
                                    <span>{$lang.i_have_read} <a href="{url app=article&act=system&code=eula}" target="_blank">{$lang.mall_eula}</a></span>
                                    <div class="clr"></div><label></label>
                                </dd>
                            </dl>
                            <dl class="clearfix">
                                <dt>&nbsp;</dt>
                                <dd>
                                    <input type="submit" name="Submit"value="{$lang.register_now}"class="register-submit"title="{$lang.register_now}" />
                                    <input type="hidden" name="ret_url" value="{$ret_url}" />
                                </dd>
                            </dl>
                        </form>                  
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="footer.html"}
